package singleton;

public class SingletonTest {
    public static void main(String[] args) {
        new  Thread(new Runnable() {
            @Override
            public void run() {
                Thread.currentThread().setName("boiler1");
                ChocolateBoiler boiler = ChocolateBoiler.getInstance();
                System.out.println(boiler);
                boiler.fill();  // 填充巧克力
                boiler.boil();  // 煮沸
                boiler.drain(); // 排出
            }
        }).start();

        new  Thread(new Runnable() {
            @Override
            public void run() {
                // 设置当前线程名称为 boiler2
                Thread.currentThread().setName("boiler2");

                ChocolateBoiler boiler = ChocolateBoiler.getInstance();
                System.out.println(boiler);

                boiler.fill();  // 填充巧克力
                boiler.boil();  // 煮沸
                boiler.drain(); // 排出
            }
        }).start();

    }
}
